package com.szjlc.requestbodyadvice.controller;


import com.szjlc.requestbodyadvice.entity.Employee;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 雇员前端控制层
 * @author steve
 * @since 2022-11-19 14:39
 */
@Slf4j
@Validated
@RestController
@RequestMapping(value = "/employee", produces = {MediaType.APPLICATION_JSON_VALUE})
public class EmployeeController {

    /** 新增雇员 */
    @PostMapping(value = "/save")
    public Employee save(@RequestBody @Validated Employee employee) {
        return null;
    }

    /** 更新雇员 */
    @PostMapping(value = "update")
    public Employee update(@RequestBody @Validated Employee employee) {
        return null;
    }

    /** 测试返回值类型为字符串 */
    @GetMapping(value = "/testString")
    public String testString() {
        return "test response body is String";
    }

    /** 批量保存 */
    @PostMapping(value = "/saveList")
    public boolean saveList(@RequestBody @Validated List<Employee> employees) {
        log.info("employees : {}", employees);
        return false;
    }
}
